package sort;

public class CountingSort {
	public static long Sort(int[] list){
		long startTime = System.currentTimeMillis();

		int maxNum=0;
		for(int i=0; i<list.length; i++)
			if(maxNum < list[i]) maxNum = list[i];
		
		int freq[] = new int[maxNum+1];
		for(int i=0; i<list.length; i++) freq[list[i]]++;
		
		for(int j=0, p=0; j<freq.length; j++)
			for(;freq[j]>0; freq[j]--) list[p++] = j;

		return System.currentTimeMillis()-startTime;
	}
}